# multiplication table
'''
说明1：学习第一周作业
说明2：用while和for…in两个循环分别输出四种九九乘法表效果
日期：2019-04-01
作者：python全栈15期班 张金慧

'''

print("*"*70)
print("1.for ..in方式输出九九乘法表，形式1")
for i in range(1,10):
	for j in range(1,i+1):
		print("{}*{}={:>2}".format(j,i,i*j),end=" ")
		j+=1
	#换行
	print("")
	i+=1

print("*"*70)
print("2.for ..in方式输出九九乘法表，形式2")
for i in range(9,0,-1):
	for j in range(1,i+1):
		print("{}*{}={:>2}".format(j,i,i*j),end=" ")
		j+=1
	#换行
	print("")
	i-=1

print("*"*70)
print("3.for ..in方式输出九九乘法表，形式3")
for i in range(1,10):
	for j in range(9,0,-1):
		if(i<j):
			print("{}{}{}{}{:>2}".format(" "," "," "," "," "),end=" ")
			j+=1
		else:
			print("{}*{}={:>2}".format(i,j,i*j),end=" ")
			j+=1
	#换行
	print("")
	i+=1

print("*"*70)
print("4.for ..in方式输出九九乘法表，形式4")
for i in range(9,0,-1):
	for j in range(9,0,-1):
		if(i<j):
			print("{}{}{}{}{:>2}".format(" "," "," "," "," "),end=" ")
			j-=1
		else:
			print("{}*{}={:>2}".format(i,j,i*j),end=" ")
			j-=1
	#换行
	print("")
	i-=1

print("*"*70)
print("5.while方式输出九九乘法表，形式1")
i=1
while i<10:
	j=1
	while j<i+1:
		print("{}*{}={:>2}".format(j,i,i*j),end=" ")
		j+=1
	#换行
	print("")
	i+=1

print("*"*70)
print("6.while方式输出九九乘法表，形式2")
i=9
while i>0:
	j=1
	while j<i+1:
		print("{}*{}={:>2}".format(j,i,i*j),end=" ")
		j+=1
	#换行
	print("")
	i-=1

print("*"*70)
print("7.while方式输出九九乘法表，形式3")
i=1
while i<10:
	j=9
	while j>0:
		if(i<j):
			print("{}{}{}{}{:>2}".format(" "," "," "," "," "),end=" ")
			j-=1
		else:
			print("{}*{}={:>2}".format(i,j,i*j),end=" ")
			j-=1
	#换行
	print("")
	i+=1

print("*"*70)
print("8.while方式输出九九乘法表，形式4")
i=9
while i>0:
	j=9
	while j>0:
		if(i<j):
			print("{}{}{}{}{:>2}".format(" "," "," "," "," "),end=" ")
			j-=1
		else:
			print("{}*{}={:>2}".format(i,j,i*j),end=" ")
			j-=1
	#换行
	print("")
	i-=1

